import Cocoa

func greet(name:String,withGreeting greeting:String) -> String
{
    return "\(greeting) \(name)"
}

let personalGreeting = greet(name: "Matt", withGreeting: "Hello,")
print(personalGreeting)



func greeting(forName name:String) -> (String)->String
{
    func greeting(_ greeting:String)->String
    {
        return"\(greeting) \(name)";
    }
    return greeting
}

let greetMattWith = greeting(forName: "Matt")
let mattGreeting = greetMattWith("Hello,")
print(mattGreeting)




struct Person
{
    var firstName = "Matt"
    var lastName = "Mathias"
    
    mutating func changeTo(firstName:String,lastName:String)
    {
        self.firstName = firstName
        self.lastName = lastName
    }
}

var p = Person()
p.changeTo(firstName: "John", lastName: "Gallagher")
p.firstName

//mutating方法的第一个参数是self，并以inout的形式传入

